<template>
  <div>
    <div class="top-panel__box">
      <el-form :model="dataForm" ref="dataForm" inline size="small" onsubmit="return false">
          <el-row>
              <el-col :span="9">
                  <el-form-item class="business-name">
                    <el-input placeholder="输入企业名称" v-model="dataForm.organceName" maxlength="30" clearable />
                  </el-form-item>
              </el-col>
              <el-col :span="6">
                  <el-form-item label="全部客群类型" label-width="100px">
                    <el-select placeholder="全部客群类型" v-model="dataForm.companyLargeType" clearable>
                      <el-option v-for="(value, key) in this.dicts['company_large_type'].childMap" :key="key" :label="value" :value="key" />
                    </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                  <el-form-item>
                    <el-button type="primary" @click="getList(1)">
                        <fa-icon class="fa-search" />查询</el-button>
                    <reset-button :dataForm.sync="dataForm" :fixedData="{pageNum: 1, pageSize: 10}" />
                  </el-form-item>
              </el-col>
          </el-row>
      </el-form>
    </div>
    <el-row class="table-top">
      <el-table :data="dataList" v-loading="tableLoading" tooltip-effect="light" class="tc-table" size="small">
        <el-table-column type="index" width="55" fixed="left" label="序号"></el-table-column>
        <template v-for="(column, index) in FOLLOW_HEAD_LIST">
          <el-table-column :prop="column.prop" :label="column.label" :key="index" :width="column.width" :show-overflow-tooltip="true" />
        </template>
      </el-table>
      <el-row class="pagination-top">
        <pagination :pageNum.sync="dataForm.pageNum" :curSizes.sync="dataForm.pageSize" :total="total" @getList="getList" />
      </el-row>
    </el-row>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import api from './api'
import { CONSTANT_OBJ } from '@/utils/constant'
import { FOLLOW_HEAD_LIST } from './js/contant.js'
export default {
  data () {
    return {
      FOLLOW_HEAD_LIST,
      tableLoading: false,
      dataForm: {
        companyLargeType: '',
        companyListType: '',
        organceName: '',
        pageNum: 0,
        pageSize: 10,
        sortField: '',
        sortType: ''
      },
      dataList: [],
      total: 0
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    // 查询列表
    getList (val) {
      this.dataForm.pageNum = val || this.dataForm.pageNum
      this.tableLoading = true
      api.queryConditionList(this.dataForm).then(res => {
        const { responseCode, data } = res
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          this.dataList = data.list || []
          this.total = parseInt(data.total) || 0
        }
      }).finally(() => {
        this.tableLoading = false
      })
    }
  },
  computed: {
    ...mapState({
      dicts: state => state.common.dicts
    })
  }
}
</script>
<style>
.business-name {
    width: 100%;
}
.business-name .el-form-item__content{
    width: 100%;
}
</style>
